package com.aurora.blog.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aurora.common.log.annotation.Log;
import com.aurora.common.log.enums.BusinessType;
import com.aurora.common.security.annotation.RequiresPermissions;
import com.aurora.blog.domain.BlogNavigationTypeConfig;
import com.aurora.blog.service.IBlogNavigationTypeConfigService;
import com.aurora.common.core.web.controller.BaseController;
import com.aurora.common.core.web.domain.AjaxResult;
import com.aurora.common.core.utils.poi.ExcelUtil;
import com.aurora.common.core.web.page.TableDataInfo;

/**
 * 导航栏标签类型配置Controller
 * 
 * @author aurora
 * @date 2024-06-07
 */
@RestController
@RequestMapping("/BlogNavigationConfig")
public class BlogNavigationTypeConfigController extends BaseController
{
    @Autowired
    private IBlogNavigationTypeConfigService blogNavigationTypeConfigService;

    /**
     * 查询导航栏标签类型配置列表
     */
    @RequiresPermissions("blog:BlogNavigationConfig:list")
    @GetMapping("/list")
    public TableDataInfo list(BlogNavigationTypeConfig blogNavigationTypeConfig)
    {
        startPage();
        List<BlogNavigationTypeConfig> list = blogNavigationTypeConfigService.selectBlogNavigationTypeConfigList(blogNavigationTypeConfig);
        return getDataTable(list);
    }

    /**
     * 导出导航栏标签类型配置列表
     */
    @RequiresPermissions("blog:BlogNavigationConfig:export")
    @Log(title = "导航栏标签类型配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BlogNavigationTypeConfig blogNavigationTypeConfig)
    {
        List<BlogNavigationTypeConfig> list = blogNavigationTypeConfigService.selectBlogNavigationTypeConfigList(blogNavigationTypeConfig);
        ExcelUtil<BlogNavigationTypeConfig> util = new ExcelUtil<BlogNavigationTypeConfig>(BlogNavigationTypeConfig.class);
        util.exportExcel(response, list, "导航栏标签类型配置数据");
    }

    /**
     * 获取导航栏标签类型配置详细信息
     */
    @RequiresPermissions("blog:BlogNavigationConfig:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(blogNavigationTypeConfigService.selectBlogNavigationTypeConfigById(id));
    }

    /**
     * 新增导航栏标签类型配置
     */
    @RequiresPermissions("blog:BlogNavigationConfig:add")
    @Log(title = "导航栏标签类型配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BlogNavigationTypeConfig blogNavigationTypeConfig)
    {
        return toAjax(blogNavigationTypeConfigService.insertBlogNavigationTypeConfig(blogNavigationTypeConfig));
    }

    /**
     * 修改导航栏标签类型配置
     */
    @RequiresPermissions("blog:BlogNavigationConfig:edit")
    @Log(title = "导航栏标签类型配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BlogNavigationTypeConfig blogNavigationTypeConfig)
    {
        return toAjax(blogNavigationTypeConfigService.updateBlogNavigationTypeConfig(blogNavigationTypeConfig));
    }

    /**
     * 删除导航栏标签类型配置
     */
    @RequiresPermissions("blog:BlogNavigationConfig:remove")
    @Log(title = "导航栏标签类型配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(blogNavigationTypeConfigService.deleteBlogNavigationTypeConfigByIds(ids));
    }
}
